﻿@using System.Web.Mvc.Ajax
@using nanoCMS.StaticPages.WebUI.Models.ViewModels
@model StaticPageAdminVM

@using (Ajax.BeginForm("Save", "StaticPages", new { }, new AjaxOptions { HttpMethod = "post", UpdateTargetId = "admin_content" }, new { }))
{
    <input type="hidden" name="PageID" id="PageVM_PageID" value="@(Model.Page.PageID)"/>
    <fieldset id="">
        <legend>Create/Edit page</legend>
        <div>
		    <label for="PageVM__Title">Title:</label> 
		    <input type="text" name="Title" id="PageVM__Title" value="@Model.Page.Title"/>
        </div>
        <div>
            <label for="PageVM_Content">Content:</label> 
		    <textarea cols="100" rows="20" name="Content" id="PageVM_Content">@Model.Page.Content</textarea>
        </div>
        <div>
            <input type="submit" value="Submit" />
        </div>
	</fieldset>
}

<div>
    @foreach (var page in Model.Pages)
    {
        <div>@page.Title</div>
        <div> 
            @Ajax.ActionLink("Edit", "Edit", "StaticPages", new { pageID = page.PageID }, new AjaxOptions { UpdateTargetId = "admin_content" })
            @Ajax.ActionLink("Delete", "Delete", "StaticPages", new { pageID = page.PageID }, new AjaxOptions { UpdateTargetId = "admin_content" })
        </div>
    }
</div>